
class ShelvePlugin(object):
    def __init__(self, indexer):
        import shelve
        self.indexer = indexer
        self._shelve = shelve.open("%s/%s/docs.shelve" % (self.indexer.index_home, self.indexer.index_name), protocol=2)

    def process_doc(self, doc):
        self._shelve[doc.get_xaphash()] = doc.get_raw_document()

        
class AspellPlugin(object):
    def __init__(self, indexer):
        import aspell
        self.indexer = indexer
        self._aspell = aspell.spell_checker()

    def process_doc(self, doc):
        for token in doc.tokeniter():
            # TODO: call aspell and save the stemmed forms somewhere
            self._aspell.suggest(token)

